package com.ruoyi.product.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.product.domain.ProductActivityCategorySkuRelation;
import com.ruoyi.product.service.IProductActivityCategorySkuRelationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 自定义分类商品关联Controller
 * 
 * @author ruoyi
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/product/activityCategorySkuRelation")
public class ProductActivityCategorySkuRelationController extends BaseController
{
    @Autowired
    private IProductActivityCategorySkuRelationService productActivityCategorySkuRelationService;

    /**
     * 查询自定义分类商品关联列表
     */
    @PreAuthorize("@ss.hasPermi('product:activityCategorySkuRelation:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductActivityCategorySkuRelation productActivityCategorySkuRelation)
    {
        startPage();
        List<ProductActivityCategorySkuRelation> list = productActivityCategorySkuRelationService.selectProductActivityCategorySkuRelationList(productActivityCategorySkuRelation);
        return getDataTable(list);
    }

    /**
     * 导出自定义分类商品关联列表
     */
    @PreAuthorize("@ss.hasPermi('product:activityCategorySkuRelation:export')")
    @Log(title = "自定义分类商品关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductActivityCategorySkuRelation productActivityCategorySkuRelation)
    {
        List<ProductActivityCategorySkuRelation> list = productActivityCategorySkuRelationService.selectProductActivityCategorySkuRelationList(productActivityCategorySkuRelation);
        ExcelUtil<ProductActivityCategorySkuRelation> util = new ExcelUtil<ProductActivityCategorySkuRelation>(ProductActivityCategorySkuRelation.class);
        util.exportExcel(response, list, "自定义分类商品关联数据");
    }

    /**
     * 获取自定义分类商品关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('product:activityCategorySkuRelation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(productActivityCategorySkuRelationService.selectProductActivityCategorySkuRelationById(id));
    }

    /**
     * 新增自定义分类商品关联
     */
    @PreAuthorize("@ss.hasPermi('product:activityCategorySkuRelation:add')")
    @Log(title = "自定义分类商品关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductActivityCategorySkuRelation productActivityCategorySkuRelation)
    {
        return toAjax(productActivityCategorySkuRelationService.insertProductActivityCategorySkuRelation(productActivityCategorySkuRelation));
    }

    @PreAuthorize("@ss.hasPermi('product:activityCategorySkuRelation:add')")
    @Log(title = "自定义分类商品关联", businessType = BusinessType.INSERT)
    @PostMapping("/addBatch")
    public AjaxResult addBatch(@RequestBody List<ProductActivityCategorySkuRelation> relationList)
    {
        return toAjax(productActivityCategorySkuRelationService.insertBatchProductActivityCategorySkuRelation(relationList));
    }

    /**
     * 修改自定义分类商品关联
     */
    @PreAuthorize("@ss.hasPermi('product:activityCategorySkuRelation:edit')")
    @Log(title = "自定义分类商品关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductActivityCategorySkuRelation productActivityCategorySkuRelation)
    {
        return toAjax(productActivityCategorySkuRelationService.updateProductActivityCategorySkuRelation(productActivityCategorySkuRelation));
    }

    /**
     * 删除自定义分类商品关联
     */
    @PreAuthorize("@ss.hasPermi('product:activityCategorySkuRelation:remove')")
    @Log(title = "自定义分类商品关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productActivityCategorySkuRelationService.deleteProductActivityCategorySkuRelationByIds(ids));
    }
}
